package com.guanyong.admin.controllers.page;


import com.guanyong.model.MessageModel;
import com.guanyong.services.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by mxk on 2017/6/6.
 */
@Controller
@RequestMapping("/page/message")
public class MessagePage  extends baseController{


    @Autowired
    MessageService messageService;


    @RequestMapping({"/list"})
    String messageList(HttpServletRequest request) {

        return  "/message/list";
    }


    @RequestMapping({"/add"})
    String messageAdd(HttpServletRequest request) {
        return "/message/messageadd";
    }

    @RequestMapping({"/update"})
    String pricetagupdate(Model model, HttpServletRequest request) {
        String fid=request.getParameter("fid");
        MessageModel messageModel =messageService.GetMessageModelById(Integer.parseInt(fid));
        if (messageModel!=null){
            model.addAttribute("messgaemodel",messageModel);
            return "/message/messageupdate";
        }
        else{
            return "errorPage/500";
        }

    }
}
